package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.spareparts.entity.InventoryAlerts;
import com.example.spareparts.service.InventoryAlertsService;
import java.util.List;

@RestController
@RequestMapping("/api/inventoryalerts")
public class InventoryAlertsController {
    @Autowired
    private InventoryAlertsService inventoryAlertsService;
    @GetMapping ("/listall")
    public List<InventoryAlerts> findAllInventoryAlerts(){
        return inventoryAlertsService.findAllInventoryAlerts();
    }
    @PostMapping ("/insert")
    public void insertInventoryAlerts(@RequestBody InventoryAlerts inventoryAlerts){

        inventoryAlertsService.insertInventoryAlerts(inventoryAlerts);
    }
    @PutMapping ("/update/{alertid}")
    public void updateInventoryAlerts(@PathVariable Long alertid, @RequestBody InventoryAlerts inventoryAlerts){
        inventoryAlerts.setAlertid(alertid);
        inventoryAlertsService.updateInventoryAlerts(inventoryAlerts);
    }
    @DeleteMapping ("/delete/{alertid}")
    public void deleteInventoryAlerts(@PathVariable Long alertid){
        inventoryAlertsService.deleteInventoryAlerts(alertid);
    }
    @GetMapping ("/findbyid/{alertid}")
    public InventoryAlerts findInventoryAlertsById(@PathVariable Long alertid){
        return inventoryAlertsService.findInventoryAlertsById(alertid);
    }
    @GetMapping ("/findbysparepartid/{sparepartid}")
    public List<InventoryAlerts> findInventoryAlertsBySparePartId(@PathVariable Long sparepartid){
        return inventoryAlertsService.findInventoryAlertsBySparePartId(sparepartid);
    }
}
